package thread_01;
//单例
//唯一实例创建实时机非常早，饿了很久，看到吃的狼吞虎咽
class Singleton{
//    JVM一启动，就立即加载
    private static Singleton instance = new Singleton();

    public static Singleton getInstance(){
        return instance;
    }

//    构造方法私有
    private Singleton(){

    }
}
public class Demo27 {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        System.out.println(s1==s2);

//        Singleton s3 = new Singleton();  报错
    }
}
